<template>
  <el-dropdown trigger="click" class="langBox" @command="changeLanguage">
    <div>
      <svg-icon style="font-size: 20px" icon-class="language" />
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item
          command="zh"
          :disabled="'zh'=== $i18n.locale "
        >中文</el-dropdown-item>
        <el-dropdown-item
          command="en"
          :disabled="'en'=== $i18n.locale "
        >en</el-dropdown-item>
      </el-dropdown-menu>
    </template>

  </el-dropdown>
</template>

<script>
export default {
  methods: {
    changeLanguage(lang) {
      this.$i18n.locale = lang
      this.$message('语言切换成功')
    }
  }
}
</script>

<style scoped>
.langBox {
  margin-right: 20px;
}
</style>